C     Last change:  ERB  16 Feb 2000   11:08 am
      SUBROUTINE MEMCHKG(ISUMGX,ISUMIG,ISUMGZ,LENGX,LENIG,LENGZ,IOUT,
     &                   IERRX,IERRU)
C
      IERR = 0
      WRITE(IOUT,10)
      WRITE(IOUT,10) ISUMGX-1,LENGX
   10 FORMAT(1X,I10,'  ELEMENTS OF GX ARRAY USED OUT OF ',I10)
      WRITE(IOUT,11) ISUMGZ-1,LENGZ
   11 FORMAT(1X,I10,'  ELEMENTS OF GZ ARRAY USED OUT OF ',I10)
      WRITE(IOUT,12) ISUMIG-1,LENIG
   12 FORMAT(1X,I10,'  ELEMENTS OF IG ARRAY USED OUT OF ',I10)
C
      IF (ISUMGX-1.GT.LENGX) IERR = IERR + 1
      IF (ISUMIG-1.GT.LENIG) IERR = IERR + 1
      IF (ISUMGZ-1.GT.LENGZ) IERR = IERR + 1
      IF (IERR.NE.0) THEN
        WRITE(IOUT,13)IERR
        WRITE(IERRU,13)IERR
        IERRX = 1
        RETURN
      ENDIF
   13 FORMAT(/,1X,I1,' ARRAY(S) NEED(S) TO BE DIMENSIONED LARGER')
C
      RETURN
      END
C=======================================================================
      SUBROUTINE MEMCHK(ISUM,ISUMI,ISUMZ,LENX,LENIX,LENZ,IOUT,ISEN,
     &                  IUHEAD,LENXHS,NCOL,NROW,NLAY,MXSEN,IERRX,IERRU,
     &                  NDD,NDAR,MPRD,MPRAR,IPRD,IPRAR)
C
      IERR = 0
      WRITE(IOUT,10)
      WRITE(IOUT,10) ISUM-1,LENX
   10 FORMAT(1X,I10,'  ELEMENTS OF X ARRAY USED OUT OF ',I10)
      WRITE(IOUT,15) ISUMZ-1,LENZ
   15 FORMAT(1X,I10,'  ELEMENTS OF Z ARRAY USED OUT OF ',I10)
      WRITE(IOUT,20) ISUMI-1,LENIX
   20 FORMAT(1X,I10,'  ELEMENTS OF IX ARRAY USED OUT OF ',I10)
      IF (ISEN.NE.0 .AND. IUHEAD.LE.0 .AND. MXSEN.GT.0) THEN
        IUXHS = NCOL*NROW*NLAY*MXSEN
      ELSE
        IUXHS = 0
      ENDIF
      WRITE(IOUT,25) IUXHS, LENXHS
      IF (IUXHS.GT.LENXHS) IERR = IERR + 1
   25 FORMAT(1X,I10,'  ELEMENTS OF XHS ARRAY USED OUT OF ',I10)
C
      IF (ISUM-1.GT.LENX) IERR = IERR + 1
      IF (ISUMI-1.GT.LENIX) IERR = IERR + 1
      IF (ISUMZ-1.GT.LENZ) IERR = IERR + 1
C
      IF (NDAR.GT.NDD) THEN
        WRITE(IOUT,27)NDAR
        WRITE(IERRU,27)NDAR
        IERR = IERR + 1
      ENDIF
   27 FORMAT(1X,'NDD IN MAIN NEEDS TO BE INCREASED TO AT LEAST ',I7)
C
      IF (MPRAR.GT.MPRD) THEN
        WRITE(IOUT,28)MPRAR
        WRITE(IERRU,28)MPRAR
        IERR = IERR + 1
      ENDIF
   28 FORMAT(1X,'MPRD IN MAIN NEEDS TO BE INCREASED TO AT LEAST ',I7)
C
      IF (IPRAR.GT.IPRD) THEN
        WRITE(IOUT,29)IPRAR
        WRITE(IERRU,29)IPRAR
        IERR = IERR + 1
      ENDIF
   29 FORMAT(1X,'IPRD IN MAIN NEEDS TO BE INCREASED TO AT LEAST ',I7)
C
      IF (IERR.NE.0) THEN
        WRITE(IOUT,30)IERR
        WRITE(IERRU,30)IERR
        IERRX = 1
        RETURN
      ENDIF
   30 FORMAT(/,1X,I1,' ARRAY(S) NEED(S) TO BE DIMENSIONED LARGER')
C
      RETURN
      END
C=======================================================================
      SUBROUTINE MEMCHKR(ISUMRX,ISUMIR,LENRX,LENIR,IOUT,IERRX,IERRU)
C
      IERR = 0
      WRITE(IOUT,10)
      WRITE(IOUT,10) ISUMRX-1,LENRX
   10 FORMAT(1X,I10,'  ELEMENTS OF RX ARRAY USED OUT OF ',I10)
      WRITE(IOUT,12) ISUMIR-1,LENIR
   12 FORMAT(1X,I10,'  ELEMENTS OF IR ARRAY USED OUT OF ',I10)
C
      IF (ISUMRX-1.GT.LENRX) IERR = IERR + 1
      IF (ISUMIR-1.GT.LENIR) IERR = IERR + 1
      IF (IERR.NE.0) THEN
        WRITE(IOUT,13)IERR
        WRITE(IERRU,13)IERR
        IERRX = 1
        RETURN
      ENDIF
   13 FORMAT(/,1X,I1,' ARRAY(S) NEED(S) TO BE DIMENSIONED LARGER')
C
      RETURN
      END
